package com.seeyon.apps.kk.listener;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.seeyon.apps.collaboration.event.CollaborationFinishEvent;
import com.seeyon.apps.collaboration.po.ColSummary;
import com.seeyon.apps.kk.manager.LockCheckworkSapManager;
import com.seeyon.apps.kk.manager.LockVacationSapManager;
import com.seeyon.ctp.common.po.template.CtpTemplate;
import com.seeyon.ctp.util.annotation.ListenEvent;
import com.seeyon.kk.utils.ValueUtils;



public class LockCheckworkListener extends BaseListener {
	private static final Log log = LogFactory.getLog(LockCheckworkListener.class);
	private LockCheckworkSapManager lockcheckmanager;
	 
	
	public LockCheckworkSapManager getLockcheckmanager() {
		return lockcheckmanager;
	}
	public void setLockcheckmanager(LockCheckworkSapManager lockcheckmanager) {
		this.lockcheckmanager = lockcheckmanager;
	}
	@ListenEvent(event = CollaborationFinishEvent.class, async = true)
	public void onFinish(CollaborationFinishEvent event)
			throws Exception {
		Thread.sleep(BaseListener.LISTENER_THREAD_SLEEPTIME);

		String templetSubject =ValueUtils.getConfig().getString("kk.LockCheckworkListener"); 
				//this.templateCode;
		ColSummary summary = this.colManager.getColSummaryById(event.getSummaryId()); // 获取协同信息
		CtpTemplate template = this.templateManager.getCtpTemplate(summary.getTempleteId());
		String[] templetSubjects = StringUtils.split(templetSubject, ",");
	 
		// template.getTempleteNumber()获取前台配置的模板编号
		if (ArrayUtils.contains(templetSubjects, template.getTempleteNumber())) {
			Long id = summary.getFormRecordid(); // 表单ID
			this.lockcheckmanager.addCheckwordForm(id); 
			}
		 
	}
		
}


